﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace frm_view
{
    public partial class frmAdmin : Form
    {
        string id = "admin";
        string pass = "admin";

        public frmAdmin()
        {
            InitializeComponent();
            SetStyle(ControlStyles.ResizeRedraw, true);
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Rectangle rc = ClientRectangle;
            if (rc.IsEmpty)
                return;
            if (rc.Width == 0 || rc.Height == 0)
                return;
            using (LinearGradientBrush brush = new LinearGradientBrush(rc, Color.White, Color.FromArgb(196, 232, 250), 90F))
            {
                e.Graphics.FillRectangle(brush, rc);
            }
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (DangNhap(txtUser.Text, txtPass.Text))
            {
                
                frmListProgram frm = new frmListProgram();
                frm.Show();
                frm.DangXuat += frm_DangXuat;
                this.Hide();
                XoaText();
            }
            else
            {
                XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không tồn tại", "Thông báo");
            }
        }

        void frm_DangXuat(object sender, EventArgs e)
        {
            //(sender as frmAdmin).Show();
           this.Show();
        }
        void XoaText()
        {
            foreach (var item1 in this.Controls)
            {

                TextBox item = item1 as TextBox;
                if (item != null)
                    item.Clear();

            }
        }

        public bool DangNhap(string id, string pass)
        {
            if (id == this.id && pass == this.pass)
            {
                return true;
            }
            return false;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
